package member.controller;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class MyPageServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	 doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		1. 로그인 여부 확인
		HttpSession session = request.getSession();
		Object mem = session.getAttribute("login_member");
//		2. 처리
		String url = null;
		if(mem!=null){
//		2-1. 로그인 했으면 member_detail.jsp로 이동
			url="/member/member_detail.jsp";
		}else{
//		2-2. 로그인 처리 않았으면 /member/login_form.jsp
			url="/member/login_form.jsp";
			request.setAttribute("error_message", "로그인 먼저 하세요");
		}
		RequestDispatcher rdp = request.getRequestDispatcher(url);
		rdp.forward(request, response);
		
		
	}

}
